using System.Runtime.CompilerServices;

namespace Pinwheel.Toolkits
{
    public static partial class ArrayExtensions 
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool CheckArraySize<T>(ref T[] array, int size, int max = int.MaxValue)
        {
            if (array.Length >= size) return false;
            var length = array.Length << 1;
            if (length > max) length = max;
            Array.Resize(ref array, length);
            return true;
        } 
    } 
}

